package com.peak.gateway.http;

import reactor.core.publisher.Flux;
import reactor.netty.DisposableServer;
import reactor.netty.http.server.HttpServer;

/**
 * @author likai
 * @date 2021/2/20 15:16
 * @email likai9376@163.com
 * @desc
 */
public class HttpServerDemo {

    public static void main(String[] args) {
        DisposableServer disposableServer = HttpServer.create()
                .host("127.0.0.1").port(8081)
                .handle((req, res) -> res.sendString(Flux.just("hello")))
                .bind()
                .block();

        Thread awaitThread = new Thread("server") {
            @Override
            public void run() {
                disposableServer.onDispose().block();
            }

        };
        awaitThread.setDaemon(false);
        awaitThread.start();
    }
}
